<!DOCTYPE html>
<html>
  <head>
    <title>楼盘列表</title>
    <meta charset="utf-8">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">


    <link rel="stylesheet" href="__STATIC__/mobile/css/weui.min.css">
	<link rel="stylesheet" href="__STATIC__/mobile/css/jquery-weui.css">
    <link rel="stylesheet" href="__STATIC__/mobile/css/style.min.css">
    <link rel="stylesheet" href="__STATIC__/mobile/css/demos.css">
    <link rel="stylesheet" href="__STATIC__/mobile/css/main.css">
    <link rel="stylesheet" href="__STATIC__/mobile/css/iconfont.css">
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=DA6Bw0637vf4t96C4GRhyPBMyplqG6zA"></script>
    <style>
    	.navbar {
		    height: 50px;
		    color: #000;
		    background: #ffd966;
		    position: fixed;
		    top: 0;
		    left: 0;
		    right: 0;
		    z-index: 99;
		    display: -webkit-box;
		    display: -ms-flexbox;
		    overflow: hidden;
		}
		.navbar .nav-wrap-left {
		    height: 100%;
		    width: 25%;
		    line-height: 50px;
		}
		.navbar .nav-wrap-left .nav-btn {
		    padding-right: 0;
		}
		.navbar .nav-btn {
		    padding: 0 0 0 10%;
		   	width: 90%;
		   	height: 100%;
		    display: block;
		    color: #000;
		    font-size: 14px;
		}
		/*a:active, a:focus, a:hover, a:visited {
		    color: #bbb;
		}*/
		a, a:hover, del, ins, s, u {
		    text-decoration: none;
		}
		.barbtn, a, button, em, input, textarea {
		    -webkit-tap-highlight-color: rgba(255,0,0,0);
		}
		a {
		    color: #222;
		    text-decoration: none;
		    outline: 0;
		}
		.navbar .nav-title {
			width: 50%;
		    height: 100%;
		    overflow: hidden;
		    line-height: 50px;
		    text-align: center;
		    -webkit-box-flex: 1;
		    -ms-flex: 1;
		}
		.navbar .nav-wrap-right {
		    height: 100%;
		    width: 25%;
		    line-height: 50px;
		    text-align: right;
		}
		.filterbar .dropdown-toggle.active {
		    color: #179b16;
		}
		.icon-xuanzechengshi {
			font-size: 8px!important;
		}
		#joblist .list-item .salary span, #loadMore .list-item .salary span, #recommend-job .list-item .salary span {
		    color: #179b16;
		    font-size: .42rem;
		}
		.pic {
			width: 55px!important;
		}
		.pic img{
			width: 55px!important;
			height: 55px;
		}
		.filterbar .dropdown-wrapper {
		    position: absolute;
		    width: 100%;
		    z-index: inherit;
		}
		.filterbar .nav {
		    position: relative;
    		z-index: inherit;
		}
		.block {
			display: block;
		}
		.none {
			display: none;
		}
		.filterbar .nav {
		    display: -webkit-box;
		    display: -ms-flexbox;
		    background: #fff;
		    border-bottom: 1px solid #e5e5e5;
		    text-align: center;
		    height: .86rem;
		    line-height: .86rem;
		    -webkit-user-select: none;
		    font-size: 13px;
		    text-align: center;
		}
		.main {
			padding: 0!important;
			/*margin-top: 50px; */
			z-index: 9999999;
		}
		.filterbar .category-wrapper {
		    overflow: scroll;
		}
		.category-wrapper {
			max-height: 480px!important;
		}
		.building_item {
			width: 25%;
			height: auto;
			overflow: hidden;
			float: left;
			text-align: center;
			font-size: 15px;
		}
		#joblist .list, #loadMore .list, #recommend-job .list {
		     padding: 0 !important; 
		}
        .weui-search-bar{margin-top:50px;}
        .weui-search-bar__label{line-height: 25px;}
    </style>
  </head>

  <body ontouchstart style="background: #fff">
  	
  	<!-- <p>Time: <span id="time">下拉我试试</span></p> -->
    <div class="navbar">
        <div class="nav-wrap-left">
            
        </div>
		<div class="nav-title">楼盘列表</div>
		<div class="nav-wrap-right">
        <if condition="$myrole neq 75">
		    <a class="nav-btn" href="{:U('addFloor')}">
		        +新增
		    </a>
        </if>
		</div>
    </div>
    <div class="weui-search-bar" id="searchBar">
      <form class="weui-search-bar__form">
        <div class="weui-search-bar__box">
          <i class="weui-icon-search"></i>
          <input type="search" class="weui-search-bar__input" id="searchInput" placeholder="搜索" required="">
          <a href="javascript:" class="weui-icon-clear" id="searchClear"></a>
        </div>
        <label class="weui-search-bar__label" id="searchText">
          <i class="weui-icon-search"></i>
          <span>搜索</span>
        </label>
      </form>
      <a href="javascript:" class="weui-search-bar__cancel-btn" id="searchCancel">取消</a>
    </div>
    <div class="main">
    	
    	<div class="filterbar">
	        <ul class="nav">
	        	<li class="dropdown-toggle" data-list="#list-re">
	                <span class="nav-head-name" id="re-title">城市</span>
	                <i class="iconfont icon-xuanzechengshi"></i>
	            </li>
	            <li class="dropdown-toggle" data-list="#list-jc">
	                <span class="nav-head-name" id="jc-title">区域</span>
	                <i class="iconfont icon-xuanzechengshi"></i>
	            </li>
	           <!--  <li class="dropdown-toggle" data-list="#list-type">
	                <span class="nav-head-name" id="type-title">楼盘</span>
	                <i class="iconfont icon-xuanzechengshi"></i>
	            </li> -->
	            <li class="dropdown-toggle" data-list="#list-sort">
	                <span class="nav-head-name" id="type-sort">总评分</span>
	                <i class="iconfont icon-xuanzechengshi"></i>
	            </li>
	        </ul>
           <div class="dropdown-wrapper">
                <ul>
                    <li class="category-wrapper" id="list-re" style="display: none">
                        <ul id="areaList" class="dropdown-list">
                            <li data-reid="all" class="active">
                                <span>全部</span>
                            </li>
                       
                        </ul>
                    </li>
                    <li class="category-wrapper" id="list-jc" style="display: none">
                        <ul id="postList" class="dropdown-list">
                             <li data-jcid="all" class="active">
                                <span>全部</span>
                            </li>
                        </ul>
                    </li>
                    <li class="category-wrapper" id="list-type" style="display: none">
                        <ul class="dropdown-list">
                             <li data-jcid="all" class="active">
                                <span>全部</span>
                            </li>
                        </ul>
                    </li>
                    <li class="category-wrapper" id="list-sort" style="display: none">
                        <ul class="dropdown-list"> 
                            <li><span>评分由高到低</span></li>
                        </ul>
                    </li>
                </ul>
            </div>
	        <div id="joblist" style="min-height: 10px">
	        	<div class="shade" style="display: none;"></div>
	        	
	            <ul id="job-all" class="list demos-content-padded" style="min-height: 10px">
                <?php foreach($info as $k=>$val):?>
	            	<li>
	                	<a href="{:U('floorDetail')}?id={$val.id}" class="list-item clearfix">
	                        <div class="building_item">
	                            {$val.city}
	                        </div>
	                        <div class="building_item">
	                            {$val.district}
	                        </div>
	                        <div class="building_item">
	                        	{$val.name}
	                        </div>
	                        <div class="building_item">
	                               <?php echo intval(get_points($val['id']));?>

	                        </div>
	                    </a>
	           		</li>
	           	<?php endforeach;?>
	            </ul>
	            
	        </div>

    	</div>
    </div>
   
	<div id="allmap1"></div>
    <script src="__STATIC__/mobile/js/jquery-2.1.4.js"></script>
    <script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
   
    <script src="__STATIC__/mobile/js/jquery-weui.js"></script>
    <script src="__STATIC__/mobile/js/pull-to-refresh.js"></script>
    <script src="__STATIC__/mobile/js/globalvariable.js"></script>
    <script src="__STATIC__/mobile/js/sose.js"></script>

  </body>
      <script>
$(function() {
  if("{$role}" == 'no'){
    $.alert({
      title: '提示',
      text: '您还无此权限哦!是否离开呢??',
      onOK: function () {
        //点击确认
        wx.closeWindow();
      }
    });
  }
  init()
  listType();

  $("#searchInput").on('input',function(e){
    var txt=$("#searchInput").val();
    if($.trim(txt)!=""){
      $("#job-all li").hide().filter(":contains('"+txt+"')").show()
    }else{
      $("#job-all li").show();
    }
  })

});
      </script>
      <script>
          
          var loading = false;
          var areaName = '';
        var cityName = '';
        var pageNo = 1;
        var pageSize = 10;
        var flag ='asc';
        var jobType = 0;
        var workType = 0;
        var tid;
        var jobTypeName;
        var workTypeName;
        var flagName;
            var city = window.localStorage.city;
            var latitude;
            var longitude;
            var first = true;
            /*
                *初始化城市列表
             */
            function init(){
                $.get('http://house.wechatpic.com/Mobile/Interface/get_city',{},function(res){
                    var res = JSON.parse(res)
                    res.forEach(function(i){
                        let city = i;
                        let li = `<li data-reid="all" class=""><span>${city}</span></li>`
                        $("#list-re ul").append(li)
                    })
                    listType()
                })
                $.get('http://house.wechatpic.com/Mobile/Interface/get_floor_search',{},function(res){
                    var res = JSON.parse(res)
                    res.name.forEach(function(i){
                        let name = i;
                        let li = `<li class=""><span>${name}</span></li>`
                        $("#list-type ul").append(li)                        
                    })
                    listType()
                })
            }        

            /*
              *根据城市获取区域信息
              *city{String} 城市
              
            */
            function getArea(city){
                $.get('http://house.wechatpic.com/Mobile/Interface/get_district',{city : city},function(res){
                      var res = JSON.parse(res)
                      $("#list-jc ul").html('<li data-jcid="19"><span>全部</span></li>')
                      res.forEach(function(i){
                                let area = i;
                                let li =  `<li data-jcid="19"><span>${area}</span></li>`
                                $("#list-jc ul").append(li)
                      })       
                      listType()           
                })    
            }         


            function listType() {
            $('.dropdown-toggle').off().on("click",function(e){
                tid = $(this).attr("data-list")
                if ($(this).hasClass('active')) {
                    $(this).removeClass("active");
                    $('.dropdown-wrapper .category-wrapper').css("display","none");
                    $(""+tid+"").fadeOut();
                    $('.shade').fadeOut();
                } else {
                    $('.dropdown-toggle').removeClass("active");
                    $(this).addClass("active");
                    $('.dropdown-wrapper .category-wrapper').css("display","none");
                    $(""+tid+"").fadeIn();
                    $('.shade').fadeIn();
                }
            });

            $(".shade").off().on('click',function(e){
                $('.shade').fadeOut();
                $(".dropdown-wrapper .category-wrapper").hide();
                $(".dropdown-toggle").removeClass("active")
            })

            $('#list-re ul li').off().on("click",function(e){

                $('#list-re ul li').removeClass("active");
                $(this).addClass("active");
                areaName = $(this).find("span").html();
                $('#re-title').html(areaName);
                getArea(areaName)
                getJobListByType(areaName,jobTypeName,workTypeName,flagName);
                $(""+tid+"").fadeOut();
                $('.shade').fadeOut();
                $('.dropdown-toggle').removeClass("active");
            })
            $('#list-jc ul li').off().on("click",function(e){
                $('#list-jc ul li').removeClass("active");
                $(this).addClass("active");
                jobTypeName = $(this).find("span").html();
                jobType = $(this).find("span").attr("data-tid");
                $('#jc-title').html(jobTypeName);
                getJobListByType(areaName,jobTypeName,workTypeName,flagName);
                $(""+tid+"").fadeOut();
                $('.shade').fadeOut();
                $('.dropdown-toggle').removeClass("active");
            })

            $('#list-type ul li').off().on("click",function(e){
                $('#list-type ul li').removeClass("active");
                $(this).addClass("active");
                workTypeName = $(this).find("span").html();
                workType = $(this).find("span").attr("data-worktype");
                $('#type-title').html(workTypeName);
                getJobListByType(areaName,jobTypeName,workTypeName,flagName);
                $(""+tid+"").fadeOut();
                $('.shade').fadeOut();
                $('.dropdown-toggle').removeClass("active");
            })

            $('#list-sort ul li').off().on("click",function(e){
                $('#list-sort ul li').removeClass("active");
                $(this).addClass("active");
                flagName = $(this).find("span").html();
                scoreSort()
                $(""+tid+"").fadeOut();
                $('.shade').fadeOut();
                $('.dropdown-toggle').removeClass("active");
            })
          }

function scoreSort(){
   $('#job-all li').sort(function(a,b){
        var oldSort =  Number($(a).find(".building_item").eq(3).text()),
            newSort = Number($(b).find(".building_item").eq(3).text());
        if( oldSort > newSort)
        return -1;
        if( oldSort < newSort)
        return 1;
        if( oldSort == newSort)
        return 0;
    }).appendTo($("#job-all"));
}

          function checkLogin() {
            // alert(window.localStorage.mid);
            if (isNull(window.localStorage.mid)) {
                $('.loginType').attr("data-type",2);
                $('.loginType').removeClass("icon-tuichudenglu").addClass("icon-iconfontwodea-copy-copy");
            } else {
                var obj = {
                    'mId':window.localStorage.mid,
                };
                doPost("account/info.web", obj, function(data) {
                    // JSON.stringify(data)
                    // alert(JSON.stringify(data));
                    if (data.success) {
                        // alert(1);
                        $('.loginType').attr("data-type",1);
                        $('.loginType').addClass("icon-tuichudenglu").removeClass("icon-iconfontwodea-copy-copy");
                    } else {
                        // alert(2);
                        $('.loginType').attr("data-type",2);
                        $('.loginType').removeClass("icon-tuichudenglu").addClass("icon-iconfontwodea-copy-copy");
                        $.toast(data.errMsg,"text");
                    }
                }, function(data) {
                      $.toast(data.errMsg,"text");
                });
            }
            
          }

          function getJobListByType(city,area,floor,comment){
                $.ajax({
                    url : 'http://house.wechatpic.com/Mobile/Interface/get_loupan_search_info',
                    data : {
                        city : city,
                        district : area,
                        loupan : floor,
                        score : comment 
                    },
                    type : 'get',
                    dataType : 'json',
                    success : function(data){
                        $("#job-all").html('');
                        data.forEach(function(i){
                            let actid = Number(i.id),
                            city = i.city,
                            district = i.district,
                            loupan = i.name,
                            score = i.score;
                            let li = `<li><a href="{:U('floorDetail')}?id=${actid}" class="list-item clearfix"><div class="building_item">${city}</div><div class="building_item">${district}</div><div class="building_item">${loupan}</div><div class="building_item">${score}</div></a></li>`
                            $("#job-all").append(li)
                        })
                    }
                })
          }

          $(window).scroll(function(){                
            var scrollh = $(document).height();  
            var bheight =  $(window).height();
            console.log("scrollh:"+scrollh+",bheight:"+bheight);
            var scrollTop=Math.max(document.documentElement.scrollTop||document.body.scrollTop);  
            if((scrollTop + $(window).height()) >= scrollh){  
                // alert("jiazai"); 
                
            }  
        }); 
      </script>
</html>
